<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">
		<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
		<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../../JS/common.js"></script>
		<script type="text/javascript" src='../../../JS/SHA-1.js'></script>
		<script type="text/javascript" src="../../../JS/BasicInfomation.js"></script>
	</head>

	<body style="padding: 0px;">
		<div class="easyui-layout" style="width:100%;height:600px;">
			<div data-options="region:'center'">
				<div>
					<table id="dg" class="table_style">
					</table>
				</div>
			</div>
		</div>
		<div id="toolbar"></div>
		<div id="dlg" class="hiddenDialog">
			<iframe id="ifrmEdit" style="width: 100%;height: 100%;" frameborder="0" scrolling="no"></iframe>
		</div>
	</body>
	<script>
		var currid = getID(); /**得到当前界面的ID**/
		var content = ""; /*定义一个空的content*/
		var DialogWidth = 810;
		var DialogHeight = 310;
		var AddDialog;
		content = AddToolBar(99 + TOOLBAR_LOAD); /**根据用户的权限，来决定生成ToolBar的哪些功能**/
		$("#toolbar").append(content); /*在ID=toolbar的标记后面添加content中的内容*/

		/*添加信息*/
		function newdata() {
			var pLocation = "EquipmentManagementAdd.html?id=-1"; /*将BoothManagementAdd.html的相对路径赋值给pLocation*/
			$("#ifrmEdit").attr("src", pLocation); /*将plocation的值当作链接，并在ID=ifrmEdit的iframe中打开*/
			constructDialog($("#dlg"), "设备信息新增", DialogWidth, DialogHeight); /*在ID=dlg的div中创建一个对话框，标题为：摊位信息，高度为：350px，宽度为：850px*/
			AddDialog.dialog('open');
		}

		/*编辑信息*/
		function editdata() {
			var pLocation = "";
			var row = $('#dg').datagrid('getSelected');
			if(!row) {
				$.messager.alert('Info', "请选择你需要修改数据"); /*判断是否有表格被选中，如果没有，则弹出警告框，提示用户修改数据*/
				return;
			}
			pLocation = "EquipmentManagementAdd.html?id=" + row.ID; /*将BoothManagementAdd.html的相对路径与被选中行的ID赋值给pLocation*/
			$("#ifrmEdit").attr("src", pLocation); /*将plocation的值当作链接，并在ID=ifrmEdit的iframe中打开*/
			constructDialog($("#dlg"), "设备信息修改", DialogWidth, DialogHeight); /*在ID=dlg的div中创建一个对话框，标题为：摊位信息，高度为：350px，宽度为：850px*/
			AddDialog.dialog('open'); 
		}
		
		//导出
		function loaddata(){
			if(currid === AddFlag) {
				$.messager.alert("警告", "该订单为新增订单，无法导出Excel！");
				return;
			}
			$.messager.confirm("提示", "确认导出Excel表格吗？", function(r) {
				if(r) {
					$.ajax({ //调用ajax方法，从服务器获取到该订单的所有数据
						type: "get",
						url: RemoteLinkAddress + "/market/device/excel.do",
						dataType: "json", //服务器返回的数据类型
						success: function(result) {
							window.location.href = result.path;
						}, //请求成功后，接受服务器传来的Json字符串，并做相应的处理
						error: function(xhr, status, error) {
							$.messager.alert("错误", "请求失败!");
						}
					});
				}
			});
		}

		function findmore() {
			var row = $('#dg').datagrid('getSelected');
			if(!row) {
				$.messager.alert('提示信息', '未选中数据!');
			}
			var pLocation = "UI/Market/EquipmentManagement/EquipmentManagement.html?id=" + row.ID;
			AddTabIn("设备相关信息", parent.parent.$("#tabs"), pLocation);
		}
		
		function redodata() {
			var _url = RemoteLinkAddress + '/market/device/list.do';
			$.ajax({
				dataType: "json",
				type: "get",
				url: _url,
				success: function(result) {
					if(result != null) {
						var _data = result;
						$('#dg').datagrid('loadData', _data);
					}
				},
				error: function(xhr, status, error) {
					$.messager.alert("错误", "请求失败!");
				}
			});
		}
		
		function dialogClose() {
			AddDialog.dialog('close');
		}
		
		$('#dg').datagrid({
			url: RemoteLinkAddress + "/market/device/list.do",
			toolbar: '#toolbar',
			method: 'get',
			pagination: 'true',
			rownumbers: 'true',
			fitColumns: 'false',
			singleSelect: 'true',
			height: 350,
			/*表格中的列名以及各自列名的ID*/
			columns: [
				[{
					field: 'ID',
					title: 'ID',
					width: '0%',
					align: 'center'
				}, {
					field: 'DEVICE_NO',
					title: '设备编号',
					width: '16%',
					align: 'center'
				}, {
					field: 'NAME',
					title: '设备名称',
					width: '17%',
					align: 'center'
				}, {
					field: 'DEVICE_TYPE',
					title: '设备类型',
					width: '17%',
					align: 'center'
				}, {
					field: 'DEVICE_RP',
					title: '设备负责人',
					width: '17%',
					align: 'center'
				},  {
					field: 'PRODUCTION_TIME',
					title: '生产日期',
					width: '15%',
					align: 'center'
				}, {
					field: 'ISVERIFY',
					title: '审核状态',
					width: '13%',
					align: 'center',
					formatter: function(value, row, index) {
						return verifyStatus(value, false);
					}
				},]
			],
			onDblClickRow: function(index, row) {
				var pLocation = "EquipmentManagementAdd.html?ID=" + row.ID;
				$("#ifrmEdit").attr("src", pLocation);
				constructDialog($("#dlg"), "设备信息修改", DialogWidth, DialogHeight);
				AddDialog.dialog('open');
			}
		});
		$('#dg').datagrid('hideColumn', 'ID');
		
	</script>

</html>